<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		*{text-align:center;}
	</style>
</head>
<body>
	 <h1>简易计算器</h1>
	 <p>第一个数字<input type="txt" name="" id="num1"></p>
	 <p>第二个数字<input type="txt" name="" id="num2"></p>
	 <hr/>
	 <input type="button"  value="+" onclick="getResult('+')">
	 <input type="button"  value="-" onclick="getResult('-')">
	 <input type="button"  value="*" onclick="getResult('*')">
	 <input type="button"  value="/" onclick="getResult('/')">
	 <hr/>
	 <p>计算结果等于：<span id="Result">0</span></p>
</body>
     <script>
     	   function getResult(opa){
     	   	var num1=Number(document.getElementById("num1").value);
     	   	var num2=Number(document.getElementById("num2").value);
     	   	switch(opa){
                 case'+':
                 Result.innerText=num1+num2;
                 break;
                 case'-':
                 Result.innerText=num1-num2;
                 break;
                 case'*':
                 Result.innerText=num1*num2;
                 break;
                 case'/':
                 Result.innerText=num1/num2;
                 break;
     	   	}
     	   }
     </script>
</html>